package data

import "zxs-micro-2/zxs-micro-proto/serverfindpb/serverfind"

type ServerData struct {
	ServerAddr     string
	ServerId       string
	ServerType     string
	ServerProtocol string
}

type ServerDataIntf interface {
	AddNewServer(string, string, string, string)
	GetServerListByType(string) []*ServerData
	DeleteServer(string)
	GetServerListByIds([]string) []*ServerData
}

var i ServerDataIntf

func init() {
	i = new(LocalMemServerData)
}

func (s *ServerData) ToPb() *serverfind.ServerStruct {
	ss := new(serverfind.ServerStruct)
	ss.ServerId = s.ServerId
	ss.ServerIpAddr = s.ServerAddr
	ss.ServerProtocol = s.ServerProtocol
	return ss
}

func GetServerDataInterface(types string) ServerDataIntf {
	//暂时只有本地的。。。后续考虑加redis或者etcd
	return i
}
